home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 090 / v7n13.arc / TRYQFN.ASM < prev    next >
Assembly Source File  |  1988-06-06  |  4KB  |  124 lines

  1.         name    tryqfn
  2.         title   TRYQFN -- QFN demo
  3.         page    55,132
  4.  
  5. ;
  6. ; TRYQFN.ASM --- demo of QFN routine
  7. ;
  8. ; Ray Duncan, February 1988
  9. ;
  10.  
  11. cr      equ     0dh             ; ASCII carriage return
  12. lf      equ     0ah             ; ASCII line feed
  13.  
  14. stdin   equ     0               ; standard input handle
  15. stdout  equ     1               ; standard output handle
  16. stderr  equ     2               ; standard error handle
  17.  
  18.  
  19. DGROUP  group   _DATA
  20.  
  21. _DATA   segment word public 'DATA'
  22.  
  23. ibuff   db      80 dup (0)      ; input buffer
  24.  
  25. msg1    db      cr,lf,lf        
  26.         db      'Enter filename:        '
  27. msg1_len equ $-msg1
  28.  
  29. msg2    db      cr,lf
  30.         db      'The full pathname is:  '
  31. msg2_len equ $-msg2
  32.  
  33. msg3    db      cr,lf
  34.         db      'Bad filename!'
  35. msg3_len equ $-msg3
  36.  
  37. _DATA   ends
  38.  
  39.  
  40. _TEXT   segment word public 'CODE'
  41.  
  42.         extrn   qfn:near
  43.  
  44.         assume  cs:_TEXT,ds:DGROUP
  45.  
  46. main    proc    near
  47.                                 
  48.         mov     ax,_DATA        ; make our data segment
  49.         mov     ds,ax           ; addressable...
  50.         mov     es,ax
  51.  
  52. main1:                          ; display prompt...
  53.                                 ; address of message
  54.         mov     dx,offset DGROUP:msg1
  55.         mov     cx,msg1_len     ; length of message
  56.         mov     bx,stdout       ; standard output handle
  57.         mov     ah,40h          ; function 40h = write
  58.         int     21h             ; transfer to MS-DOS
  59.  
  60.                                 ; get a filename...
  61.                                 ; address of buffer
  62.         mov     dx,offset DGROUP:ibuff  
  63.         mov     cx,64           ; maximum entry length
  64.         mov     bx,stdin        ; standard input handle
  65.         mov     ah,3fh          ; function 3fh = read
  66.         int     21h             ; transfer to MS-DOS
  67.  
  68.         cmp     ax,2            ; anything entered?
  69.         je      main3           ; empty line, exit
  70.  
  71.                                 ; call QFN routine to
  72.                                 ; validate and qualify
  73.                                 ; the filename...
  74.  
  75.         sub     ax,2            ; AX = length (decrease
  76.                                 ; to remove CR-LF)
  77.                                 ; DS:SI = addr of filename
  78.         mov     si,offset DGROUP:ibuff
  79.         call    qfn             ; go qualify filename
  80.         jc      main2           ; jump if bad filename
  81.  
  82.         push    si              ; save qualified filename
  83.         push    ax              ; address and length
  84.  
  85.                                 ; first display title...
  86.         mov     dx,offset DGROUP:msg2
  87.         mov     cx,msg2_len     ; message length
  88.         mov     bx,stdout       ; standard output handle
  89.         mov     ah,40h          ; function 40h = write
  90.         int     21h             ; transfer to MS-DOS
  91.  
  92.         pop     cx              ; get filename length
  93.         pop     dx              ; get filename address
  94.         mov     bx,stdout       ; standard output handle
  95.         mov     ah,40h          ; function 40h = write
  96.         int     21h             ; transfer to MS-DOS
  97.  
  98.         jmp     main1           ; get another filename
  99.  
  100. main2:                          ; display error message...
  101.                                 ; address of message
  102.         mov     dx,offset DGROUP:msg3
  103.         mov     cx,msg3_len     ; length of message     
  104.         mov     bx,stdout       ; standard output handle
  105.         mov     ah,40h          ; function 40h = write
  106.         int     21h             ; transfer to MS-DOS
  107.         jmp     main1           ; get another filename
  108.                 
  109. main3:  mov     ax,4c00h        ; terminate with
  110.         int     21h             ; return code = 0
  111.  
  112. main    endp
  113.         
  114. _TEXT   ends
  115.  
  116.  
  117. STACK   segment para stack 'STACK'
  118.         
  119.         db      128 dup (?)
  120.  
  121. STACK   ends
  122.  
  123.         end     main
  124.